﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "使用viewstate保存用户点击按钮的次数";
        if (!this.IsPostBack)
        {
            this.ViewState["num"] = 0;
        }
        else
        {
            this.ViewState["num"] = (int)this.ViewState["num"] + 1;
        }
        this.Label1.Text = "这是你第" + this.ViewState["num"].ToString() + "次使用了按钮";

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    }
}
